home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / swindows.zip / WINDCHIL.PAS < prev    next >
Pascal/Delphi Source File  |  1989-12-09  |  6KB  |  215 lines

  1. {$R-,B+,S+,I+,N-}
  2.  
  3. {                   Residential Building Energy Program
  4.                 Wind Chill Temperature Calculation Program
  5.                         March 1988 - Version 1.2                         }
  6. program WindChil;
  7.  
  8.  
  9. Uses
  10.   Crt,
  11.   Input,
  12.   Dos;
  13.  
  14. Label TempInput, SpeedInput;
  15.  
  16. var
  17.    CommandData:  String[15];
  18.    InError:      Boolean;
  19.    i,j,
  20.    Code:         Integer;
  21.    Temperature,
  22.    WindSpeed,
  23.    WindChill:    Real;
  24.  
  25. procedure PaintScreen;
  26.  
  27.    begin
  28.  
  29. WindChill := 0.0817 * (3.17 * Sqrt(WindSpeed) + 5.81 - 0.25 * WindSpeed) * (Temperature - 91.4) + 91.4;
  30.  
  31.          GotoXY(1,8);
  32.          TextColor(LightCyan);
  33.          Write('                Dry Bulb Temperature:');
  34.          TextColor(White);
  35.          Write(Temperature:4:0);
  36.          TextColor(LightCyan);
  37.          Writeln(' degrees F');
  38.          Writeln;
  39.          Write('                          Wind Speed:');
  40.          TextColor(White);
  41.          Write(WindSpeed:4:0);
  42.          TextColor(LightCyan);
  43.          Writeln(' MPH');
  44.          Writeln;
  45.          TextColor(Yellow);
  46.          Write('           Wind Chill Temperature is:');
  47.          TextColor(White);
  48.          Write(WindChill:4:0);
  49.          TextColor(Yellow);
  50.          Writeln(' degrees F');
  51.          GotoXY(1,25);
  52.          TextColor(White);
  53.          Write('<Ctrl End>  ');
  54.          TextColor(LightCyan);
  55.          Write('To Exit.                      ');
  56.          TextColor(LightGray);
  57.    end;
  58.  
  59. begin
  60.    TextColor(LightGray);
  61.    ClrScr;
  62.    TextColor(Yellow);
  63.    Writeln('                          Simple Software Solutions');
  64.    TextColor(LightCyan);
  65.    Writeln('                   Wind Chill Factor Calculation Program');
  66.    Writeln('                    Version 1.4 by David C. Swaim, Ph.D.');
  67.    Writeln;
  68.    Writeln;
  69.    Writeln;
  70.  
  71.    if ParamCount=2 then
  72.  
  73.       begin
  74.          CommandData := ParamStr(1);
  75.          Val(CommandData,Temperature,Code);
  76.          if Code<>0 then
  77.             begin
  78.                TextColor(LightRed+Blink);
  79.                Writeln;
  80.                Writeln('Temperature Must be Numeric!');
  81.                Writeln;
  82.                TextColor(Yellow);
  83.                Write('WINDCHIL ');
  84.                for i := 1 to 2 do
  85.                   begin
  86.                      Write(ParamStr(i),' ');
  87.                   end;
  88.                Writeln;
  89.                Halt;
  90.             end
  91.          else
  92.             begin
  93.                if Temperature >= 32 then
  94.                   begin
  95.                      TextColor(LightRed+Blink);
  96.                      Writeln;
  97.                      Writeln('Temperature Must be Less than 32 Degrees!');
  98.                      Writeln;
  99.                      TextColor(Yellow);
  100.                      Write('WINDCHIL ');
  101.                      for i := 1 to 2 do
  102.                         begin
  103.                            Write(ParamStr(i),' ');
  104.                         end;
  105.                      Writeln;
  106.                      Halt;
  107.                   end;
  108.             end;
  109.          CommandData := ParamStr(2);
  110.          Val(CommandData,WindSpeed,Code);
  111.          if Code<>0 then
  112.             begin
  113.                TextColor(LightRed+Blink);
  114.                Writeln;
  115.                Writeln('Wind Speed Must be Numeric!');
  116.                Writeln;
  117.                TextColor(Yellow);
  118.                Write('WINDCHIL ');
  119.                for i := 1 to 2 do
  120.                   begin
  121.                      Write(ParamStr(i),' ');
  122.                   end;
  123.                Writeln;
  124.                Halt;
  125.             end
  126.          else
  127.             begin
  128.                if WindSpeed <= 10 then
  129.                   begin
  130.                      TextColor(LightRed+Blink);
  131.                      Writeln;
  132.                      Writeln('Wind Speed Must be Greater than 10 MPH!');
  133.                      Writeln;
  134.                      TextColor(Yellow);
  135.                      Write('WINDCHIL ');
  136.                      for i := 1 to 2 do
  137.                         begin
  138.                            Write(ParamStr(i),' ');
  139.                         end;
  140.                      Writeln;
  141.                      Halt;
  142.                   end;
  143.             end;
  144.  
  145.             PaintScreen;
  146.  
  147.       end
  148.  
  149.    else
  150.  
  151.       begin
  152.          Temperature := 30;
  153.          WindSpeed := 20;
  154.          PaintScreen;
  155.          Numin := True;
  156.          Insrt := False;
  157.          j := 0;
  158.  
  159.          While Control <> Esc do
  160.                begin
  161.                  InError := False;
  162.                  Case j of
  163.                     0: begin
  164.                          x := 39;
  165.                          y := 8;
  166.                          Maxin := 3;
  167.                          Str(Temperature:3:0,Indata);
  168.                        end;
  169.                     1: begin
  170.                          x := 40;
  171.                          y := 10;
  172.                          Maxin := 2;
  173.                          Str(WindSpeed:2:0,Indata);
  174.                        end;
  175.                  end;
  176.  
  177.                  Getin(Numin,FileIn,Maxin,x,y,Indata,Insrt,Control,Number);
  178.  
  179.                  Case j of
  180.                       0: begin
  181.                            Temperature := Number;
  182.                            if Temperature >= 32 then
  183.                               begin
  184.                                 TextColor(LightRed+Blink);
  185.                                 GotoXY(1,25);
  186.                                 Write('Temperature Must be Less than 32 Degrees!');
  187.                                 TextColor(White);
  188.                                 InError := True;
  189.                               end;
  190.                          end;
  191.                       1: begin
  192.                            WindSpeed := Number;
  193.                            if WindSpeed <= 10 then
  194.                               begin
  195.                                 TextColor(LightRed+Blink);
  196.                                 GotoXY(1,25);
  197.                                 Write('Wind Speed Must be Greater than 10 MPH!');
  198.                                 TextColor(White);
  199.                                 InError := True;
  200.                               end;
  201.                          end;
  202.                  end;
  203.                  if InError then
  204.                     Write(Beep)
  205.                  else
  206.                     begin
  207.                       PaintScreen;
  208.                       j := 1 - j;
  209.                     end;
  210.                end;
  211.          ClrScr;
  212.          CursorOn;
  213.       end;
  214. end.
  215.